package com.lib.image.until

import android.content.Context
import android.content.pm.PackageManager
import android.os.Build
import android.os.Build.VERSION

object PermissionsUntil {

    fun isGranted(context: Context, permission: String): Boolean {
        return if (VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            isMarshmallow() || context.checkSelfPermission(permission) == PackageManager.PERMISSION_GRANTED
        } else {
            return true
        }
    }

    private fun isMarshmallow(): Boolean {
        return VERSION.SDK_INT >= 23
    }
}